﻿using System.ComponentModel.DataAnnotations;
using Lari.Services.Data;

namespace Lari.Services.ViewModel
{
    public class EmployeesUsersViewModel
    {
        
        [Required]
        public int Id
        {
            get;
            set;
        }
        [StringLength(20)]
        public string UserId
        {
            get;
            set;
        }
        [Required]
        [StringLength(75)]
        public string FirstName
        {
            get;
            set;
        }
        [StringLength(25)]
        public string Middlename
        {
            get;
            set;
        }
        [Required]
        [StringLength(75)]
        public string LastName
        {
            get;
            set;
        }
        [StringLength(20)]
        public string Mobile
        {
            get;
            set;
        }
        [Required]
        public int DepartmentId
        {
            get;
            set;
        }
        public int? DesignationId
        {
            get;
            set;
        }
        [StringLength(50)]
        public string Email
        {
            get;
            set;
        }
        [Required]
        public bool IsConsultant
        {
            get;
            set;
        }
        [StringLength(301)]
        public string SearchString
        {
            get;
            set;
        }
        public int? IsProfileMapped
        {
            get;
            set;
        }
    }

    public static partial class Extension
    {
        public static EmployeesUsersViewModel ConvertToViewModel(this EmployeesUsersView model)
        {
            var view = new EmployeesUsersViewModel
                           {
                               Id = model.Id,
                               UserId = model.UserId,
                               FirstName = model.FirstName,
                               Middlename = model.Middlename,
                               LastName = model.LastName,
                               Mobile = model.Mobile,
                               DepartmentId = model.DepartmentId,
                               DesignationId = model.DesignationId,
                               Email = model.Email,
                               IsConsultant = model.IsConsultant,
                               SearchString = model.SearchString,
                               IsProfileMapped = model.IsProfileMapped
                           };

            return view;
        }

        public static EmployeesUsersView ConvertToEntityModel(this EmployeesUsersViewModel view)
        {
            var model = new EmployeesUsersView
                            {
                                Id = view.Id,
                                UserId = view.UserId,
                                FirstName = view.FirstName,
                                Middlename = view.Middlename,
                                LastName = view.LastName,
                                Mobile = view.Mobile,
                                DepartmentId = view.DepartmentId,
                                DesignationId = view.DesignationId,
                                Email = view.Email,
                                IsConsultant = view.IsConsultant,
                                SearchString = view.SearchString,
                                IsProfileMapped = view.IsProfileMapped
                            };

            return model;   
        } 
    }
}
